﻿<template>
	<div class="card-fill layout-padding" v-loading="loading" element-loading-text="Loading...">
		<el-tabs v-model="activeTab">
			<el-tab-pane label="基本信息" name="main">
				<el-card shadow="hover" class="layout-padding-auto create-form">
					<el-form ref="formRef" :model="stateData.vmModel" label-width="120px">
						<div class="form-section">
							<div class="section-title">
								<i class="_wtmicon _wtmicon-wxbzhanghu"></i>
								<span>应聘信息</span>
							</div>

							<el-row :gutter="20">
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_RecruitPublishId_FormItem" prop="Entity.RecruitPublishRequestBillId">
										<template #label>
											<WtmLabelTooltip label="招聘发布单" tooltip="招聘发布单" />
										</template>
										<el-input v-model="recruitPublishDisplayName" disabled clearable class="width100"></el-input>
									</el-form-item>
								</el-col>
								<!-- <el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_ArrivalDate_FormItem" prop="Entity.ArrivalDate">
										<template #label>
											<WtmLabelTooltip label="可到岗时间" tooltip="可到岗时间" />
										</template>
										<el-date-picker v-model="stateData.vmModel.Entity.ArrivalDate" disabled clearable class="width100"></el-date-picker>
									</el-form-item>
								</el-col> -->
								<!-- 基本应聘信息 -->
								<el-row :gutter="20" class="mb20">
									<el-col :xs="24" :lg="12">
										<el-form-item ref="Entity_CurrentSalary_FormItem" prop="Entity.CurrentSalary">
											<template #label>
												<WtmLabelTooltip label="原薪酬" tooltip="原薪酬" />
											</template>
											<el-input-number v-model="stateData.vmModel.Entity.CurrentSalary" disabled clearable class="width100"></el-input-number>
										</el-form-item>
									</el-col>
									<el-col :xs="24" :lg="12">
										<el-form-item ref="Entity_ExpectedSalary_FormItem" prop="Entity.ExpectedSalary">
											<template #label>
												<WtmLabelTooltip label="期望薪酬" tooltip="期望薪酬" />
											</template>
											<el-input-number v-model="stateData.vmModel.Entity.ExpectedSalary" disabled clearable class="width100"></el-input-number>
										</el-form-item>
									</el-col>
								</el-row>

								<!-- ====== 初试信息 ====== -->
								<el-divider content-position="left">
									<span style="font-size: 14px; font-weight: bold; color: #409eff"> <i class="el-icon-edit-outline"></i> 初试信息 </span>
								</el-divider>
								<el-row :gutter="20">
									<el-col v-if="fieldController.show('InitialTestTime')" :xs="24" :lg="8" class="mb20">
										<el-form-item ref="Entity_InitialTestTime_FormItem" prop="Entity.InitialTestTime">
											<template #label>
												<WtmLabelTooltip label="初试时间" tooltip="初试时间" />
											</template>
											<el-date-picker
												v-model="stateData.vmModel.Entity.InitialTestTime"
												:disabled="!fieldController.edit('InitialTestTime')"
												clearable
												class="width100"
												type="datetime"
												placeholder="请选择初试时间"
												format="YYYY-MM-DD HH:mm"
												value-format="YYYY-MM-DD HH:mm:ss"
											>
											</el-date-picker>
										</el-form-item>
									</el-col>
									<el-col v-if="fieldController.show('InitialResult')" :xs="24" :lg="8" class="mb20">
										<el-form-item ref="Entity_InitialResult_FormItem" prop="Entity.InitialResult">
											<template #label>
												<WtmLabelTooltip label="初试结果" tooltip="初试结果" />
											</template>
											<el-select
												v-model="stateData.vmModel.Entity.InitialResult"
												:disabled="!fieldController.edit('InitialResult')"
												clearable
												class="width100"
												placeholder="请选择初试结果"
											>
												<el-option key="通过" value="通过" label="通过">
													<span style="color: #67c23a">✓ 通过</span>
												</el-option>
												<el-option key="不通过" value="不通过" label="不通过">
													<span style="color: #f56c6c">✗ 不通过</span>
												</el-option>
												<el-option key="待定" value="待定" label="待定">
													<span style="color: #e6a23c">◯ 待定</span>
												</el-option>
											</el-select>
										</el-form-item>
									</el-col>
									<el-col v-if="fieldController.show('InitialComment')" :xs="24" :lg="8" class="mb20">
										<el-form-item ref="Entity_InitialComment_FormItem" prop="Entity.InitialComment">
											<template #label>
												<WtmLabelTooltip label="初试评语" tooltip="初试评语" />
											</template>
											<el-input
												v-model="stateData.vmModel.Entity.InitialComment"
												type="textarea"
												:rows="3"
												:disabled="!fieldController.edit('InitialComment')"
												clearable
												class="width100"
												placeholder="请输入初试评语"
											></el-input>
										</el-form-item>
									</el-col>
								</el-row>

								<!-- ====== 复试信息 ====== -->
								<el-divider content-position="left">
									<span style="font-size: 14px; font-weight: bold; color: #409eff"> <i class="el-icon-edit-outline"></i> 复试信息 </span>
								</el-divider>
								<el-row :gutter="20">
									<el-col v-if="fieldController.show('ReExamTime')" :xs="24" :lg="8" class="mb20">
										<el-form-item ref="Entity_ReExamTime_FormItem" prop="Entity.ReExamTime">
											<template #label>
												<WtmLabelTooltip label="复试时间" tooltip="复试时间" />
											</template>
											<el-date-picker
												v-model="stateData.vmModel.Entity.ReExamTime"
												:disabled="!fieldController.edit('ReExamTime')"
												clearable
												class="width100"
												type="datetime"
												format="YYYY-MM-DD HH:mm"
												value-format="YYYY-MM-DD HH:mm:ss"
												placeholder="请选择复试时间"
											>
											</el-date-picker>
										</el-form-item>
									</el-col>
									<el-col v-if="fieldController.show('ReExamResult')" :xs="24" :lg="8" class="mb20">
										<el-form-item ref="Entity_ReExamResult_FormItem" prop="Entity.ReExamResult">
											<template #label>
												<WtmLabelTooltip label="复试结果" tooltip="复试结果" />
											</template>
											<el-select
												v-model="stateData.vmModel.Entity.ReExamResult"
												:disabled="!fieldController.edit('ReExamResult')"
												clearable
												class="width100"
												placeholder="请选择复试结果"
											>
												<el-option key="通过" value="通过" label="通过">
													<span style="color: #67c23a">✓ 通过</span>
												</el-option>
												<el-option key="不通过" value="不通过" label="不通过">
													<span style="color: #f56c6c">✗ 不通过</span>
												</el-option>
												<el-option key="待定" value="待定" label="待定">
													<span style="color: #e6a23c">◯ 待定</span>
												</el-option>
											</el-select>
										</el-form-item>
									</el-col>
									<el-col v-if="fieldController.show('ReExamComment')" :xs="24" :lg="8" class="mb20">
										<el-form-item ref="Entity_ReExamComment_FormItem" prop="Entity.ReExamComment">
											<template #label>
												<WtmLabelTooltip label="复试评语" tooltip="复试评语" />
											</template>
											<el-input
												v-model="stateData.vmModel.Entity.ReExamComment"
												type="textarea"
												:rows="3"
												:disabled="!fieldController.edit('ReExamComment')"
												clearable
												class="width100"
												placeholder="请输入复试评语"
											></el-input>
										</el-form-item>
									</el-col>
								</el-row>

								<!-- ====== 笔试信息 ====== -->
								<el-divider content-position="left">
									<span style="font-size: 14px; font-weight: bold; color: #409eff"> <i class="el-icon-document"></i> 笔试信息 </span>
								</el-divider>
								<el-row :gutter="20">
									<el-col v-if="fieldController.show('WrittenTestTime')" :xs="24" :lg="8" class="mb20">
										<el-form-item ref="Entity_WrittenTestTime_FormItem" prop="Entity.WrittenTestTime">
											<template #label>
												<WtmLabelTooltip label="笔试时间" tooltip="笔试时间" />
											</template>
											<el-date-picker
												v-model="stateData.vmModel.Entity.WrittenTestTime"
												:disabled="!fieldController.edit('WrittenTestTime')"
												clearable
												class="width100"
												type="datetime"
												placeholder="请选择笔试时间"
												format="YYYY-MM-DD HH:mm"
												value-format="YYYY-MM-DD HH:mm:ss"
											>
											</el-date-picker>
										</el-form-item>
									</el-col>
									<el-col v-if="fieldController.show('WrittenTestScore')" :xs="24" :lg="8" class="mb20">
										<el-form-item ref="Entity_WrittenTestScore_FormItem" prop="Entity.WrittenTestScore">
											<template #label>
												<WtmLabelTooltip label="笔试成绩" tooltip="笔试成绩" />
											</template>
											<el-input-number
												v-model="stateData.vmModel.Entity.WrittenTestScore"
												:disabled="!fieldController.edit('WrittenTestScore')"
												:min="0"
												:max="100"
												:precision="2"
												clearable
												class="width100"
												placeholder="请输入笔试成绩"
											></el-input-number>
										</el-form-item>
									</el-col>
									<el-col v-if="fieldController.show('WrittenTestResult')" :xs="24" :lg="8" class="mb20">
										<el-form-item ref="Entity_WrittenTestResult_FormItem" prop="Entity.WrittenTestResult">
											<template #label>
												<WtmLabelTooltip label="笔试结果" tooltip="笔试结果" />
											</template>
											<el-input
												v-model="stateData.vmModel.Entity.WrittenTestResult"
												:disabled="!fieldController.edit('WrittenTestResult')"
												clearable
												class="width100"
												placeholder="请输入笔试结果"
											></el-input>
										</el-form-item>
									</el-col>
								</el-row>

								<!-- ====== 体检信息 ====== -->
								<el-divider content-position="left">
									<span style="font-size: 14px; font-weight: bold; color: #409eff"> <i class="el-icon-first-aid-kit"></i> 体检信息 </span>
								</el-divider>
								<el-row :gutter="20">
									<el-col v-if="fieldController.show('PhysicalExamTime')" :xs="24" :lg="8" class="mb20">
										<el-form-item ref="Entity_PhysicalExamTime_FormItem" prop="Entity.PhysicalExamTime">
											<template #label>
												<WtmLabelTooltip label="体检时间" tooltip="体检时间" />
											</template>
											<el-date-picker
												v-model="stateData.vmModel.Entity.PhysicalExamTime"
												:disabled="!fieldController.edit('PhysicalExamTime')"
												clearable
												class="width100"
												type="datetime"
												placeholder="请选择体检时间"
												format="YYYY-MM-DD HH:mm"
												value-format="YYYY-MM-DD HH:mm:ss"
											>
											</el-date-picker>
										</el-form-item>
									</el-col>
									<el-col v-if="fieldController.show('PhysicalExamResult')" :xs="24" :lg="8" class="mb20">
										<el-form-item ref="Entity_PhysicalExamResult_FormItem" prop="Entity.PhysicalExamResult">
											<template #label>
												<WtmLabelTooltip label="体检结果" tooltip="体检结果" />
											</template>
											<el-input
												v-model="stateData.vmModel.Entity.PhysicalExamResult"
												:disabled="!fieldController.edit('PhysicalExamResult')"
												clearable
												class="width100"
												placeholder="请输入体检结果"
											></el-input>
										</el-form-item>
									</el-col>
									<el-col v-if="fieldController.show('PhysicalExamRemark')" :xs="24" :lg="8" class="mb20">
										<el-form-item ref="Entity_PhysicalExamRemark_FormItem" prop="Entity.PhysicalExamRemark">
											<template #label>
												<WtmLabelTooltip label="体检说明" tooltip="体检说明" />
											</template>
											<el-input
												v-model="stateData.vmModel.Entity.PhysicalExamRemark"
												type="textarea"
												:rows="3"
												:disabled="!fieldController.edit('PhysicalExamRemark')"
												clearable
												class="width100"
												placeholder="请输入体检说明"
											></el-input>
										</el-form-item>
									</el-col>
								</el-row>

								<!-- ====== 岗前培训信息 ====== -->
								<el-divider content-position="left">
									<span style="font-size: 14px; font-weight: bold; color: #409eff"> <i class="el-icon-reading"></i> 岗前培训信息 </span>
								</el-divider>
								<el-row :gutter="20">
									<el-col v-if="fieldController.show('PreJobTrainingStartTime')" :xs="24" :lg="8" class="mb20">
										<el-form-item ref="Entity_PreJobTrainingStartTime_FormItem" prop="Entity.PreJobTrainingStartTime">
											<template #label>
												<WtmLabelTooltip label="培训开始时间" tooltip="培训开始时间" />
											</template>
											<el-date-picker
												v-model="stateData.vmModel.Entity.PreJobTrainingStartTime"
												:disabled="!fieldController.edit('PreJobTrainingStartTime')"
												clearable
												class="width100"
												type="datetime"
												placeholder="请选择培训开始时间"
												format="YYYY-MM-DD HH:mm"
												value-format="YYYY-MM-DD HH:mm:ss"
											>
											</el-date-picker>
										</el-form-item>
									</el-col>
									<el-col v-if="fieldController.show('PreJobTrainingEndTime')" :xs="24" :lg="8" class="mb20">
										<el-form-item ref="Entity_PreJobTrainingEndTime_FormItem" prop="Entity.PreJobTrainingEndTime">
											<template #label>
												<WtmLabelTooltip label="培训结束时间" tooltip="培训结束时间" />
											</template>
											<el-date-picker
												v-model="stateData.vmModel.Entity.PreJobTrainingEndTime"
												:disabled="!fieldController.edit('PreJobTrainingEndTime')"
												clearable
												class="width100"
												type="datetime"
												placeholder="请选择培训结束时间"
												format="YYYY-MM-DD HH:mm"
												value-format="YYYY-MM-DD HH:mm:ss"
											>
											</el-date-picker>
										</el-form-item>
									</el-col>
									<el-col v-if="fieldController.show('TrainingResult')" :xs="24" :lg="8" class="mb20">
										<el-form-item ref="Entity_TrainingResult_FormItem" prop="Entity.TrainingResult">
											<template #label>
												<WtmLabelTooltip label="培训结果" tooltip="培训结果" />
											</template>
											<el-input
												v-model="stateData.vmModel.Entity.TrainingResult"
												:disabled="!fieldController.edit('TrainingResult')"
												clearable
												class="width100"
												placeholder="请输入培训结果"
											></el-input>
										</el-form-item>
									</el-col>
									<el-col v-if="fieldController.show('TrainingComment')" :xs="24" :lg="24" class="mb20">
										<el-form-item ref="Entity_TrainingComment_FormItem" prop="Entity.TrainingComment">
											<template #label>
												<WtmLabelTooltip label="培训评语" tooltip="培训评语" />
											</template>
											<el-input
												v-model="stateData.vmModel.Entity.TrainingComment"
												type="textarea"
												:rows="3"
												:disabled="!fieldController.edit('TrainingComment')"
												clearable
												class="width100"
												placeholder="请输入培训评语"
											></el-input>
										</el-form-item>
									</el-col>
								</el-row>

								<!-- ====== 最终结果 ====== -->
								<el-divider content-position="left">
									<span style="font-size: 14px; font-weight: bold; color: #67c23a"> <i class="el-icon-circle-check"></i> 最终结果 </span>
								</el-divider>
								<el-row :gutter="20">
									<el-col v-if="fieldController.show('FinalResult')" :xs="24" :lg="12" class="mb20">
										<el-form-item ref="Entity_FinalResult_FormItem" prop="Entity.FinalResult">
											<template #label>
												<WtmLabelTooltip label="最终结果" tooltip="最终结果" />
											</template>
											<el-select
												v-model="stateData.vmModel.Entity.FinalResult"
												clearable
												class="width100"
												:disabled="!fieldController.edit('FinalResult')"
												placeholder="请选择最终结果"
											>
												<el-option key="录用" value="录用" label="录用">
													<span style="color: #67c23a; font-weight: bold">✓ 录用</span>
												</el-option>
												<el-option key="不录用" value="不录用" label="不录用">
													<span style="color: #f56c6c; font-weight: bold">✗ 不录用</span>
												</el-option>
												<el-option key="待定" value="待定" label="待定">
													<span style="color: #e6a23c; font-weight: bold">◯ 待定</span>
												</el-option>
											</el-select>
										</el-form-item>
									</el-col>
									<el-col v-if="fieldController.show('FinalRemark')" :xs="24" :lg="12" class="mb20">
										<el-form-item ref="Entity_FinalRemark_FormItem" prop="Entity.FinalRemark">
											<template #label>
												<WtmLabelTooltip label="最终评语" tooltip="最终评语" />
											</template>
											<el-input
												v-model="stateData.vmModel.Entity.FinalRemark"
												type="textarea"
												:rows="3"
												:disabled="!fieldController.edit('FinalRemark')"
												clearable
												class="width100"
												placeholder="请输入最终评语"
											></el-input>
										</el-form-item>
									</el-col>
								</el-row>

								<!-- <el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_RejectReason_FormItem" prop="Entity.RejectReason">
										<template #label>
											<WtmLabelTooltip label="拒绝原因" tooltip="拒绝原因" />
										</template>
										<el-input
											v-model="stateData.vmModel.Entity.RejectReason"
											type="textarea"
											:rows="3"
											disabled
											clearable
											class="width100"
										></el-input>
									</el-form-item>
								</el-col> -->
							</el-row>
						</div>

						<!-- <div class="form-section">
							<div class="section-title">
								<i class="_wtmicon _wtmicon-wxbzhanghu"></i>
								<span>单据信息</span>
							</div>

							<el-row :gutter="20">
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_BillCode_FormItem" prop="Entity.BillCode">
										<template #label>
											<WtmLabelTooltip label="单据编号" tooltip="单据编号" />
										</template>
										<el-input v-model="stateData.vmModel.Entity.BillCode" disabled clearable class="width100"></el-input>
									</el-form-item>
								</el-col>
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_BillStatus_FormItem" prop="Entity.BillStatus">
										<template #label>
											<WtmLabelTooltip label="单据状态" tooltip="单据状态" />
										</template>
										<el-select v-model="stateData.vmModel.Entity.BillStatus" disabled clearable class="width100">
											<el-option v-for="status in BILL_STATUS_OPTIONS" :key="status" :value="status" :label="status"></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_WorkflowStatus_FormItem" prop="Entity.WorkflowStatus">
										<template #label>
											<WtmLabelTooltip label="工作流状态" tooltip="工作流状态" />
										</template>
										<el-select v-model="stateData.vmModel.Entity.WorkflowStatus" disabled clearable class="width100">
											<el-option v-for="status in WORKFLOW_STATUS_OPTIONS" :key="status" :value="status" :label="status"></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_Remark_FormItem" prop="Entity.Remark">
										<template #label>
											<WtmLabelTooltip label="备注" tooltip="备注" />
										</template>
										<el-input v-model="stateData.vmModel.Entity.Remark" type="textarea" :rows="3" disabled clearable class="width100"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
						</div> -->

						<div class="form-section">
							<div class="section-title">
								<i class="_wtmicon _wtmicon-wxbzhanghu"></i>
								<span>基本信息</span>
							</div>

							<el-row :gutter="20">
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_Name_FormItem" prop="Entity.Name" :rules="[{ required: true, message: '姓名为必填项', trigger: 'blur' }]">
										<template #label>
											<WtmLabelTooltip label="姓名" tooltip="应聘者姓名" />
										</template>
										<el-input v-model="stateData.vmModel.Entity.Name" disabled clearable class="width100"></el-input>
									</el-form-item>
								</el-col>
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item
										ref="Entity_BirthDate_FormItem"
										prop="Entity.BirthDate"
										:rules="[{ required: true, message: '出生日期为必填项', trigger: 'blur' }]"
									>
										<template #label>
											<WtmLabelTooltip label="出生日期" tooltip="出生日期" />
										</template>
										<el-date-picker v-model="stateData.vmModel.Entity.BirthDate" disabled clearable class="width100"></el-date-picker>
									</el-form-item>
								</el-col>
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item
										ref="Entity_Gender_FormItem"
										prop="Entity.Gender"
										:rules="[{ required: true, message: '性别为必填项', trigger: 'blur' }]"
									>
										<template #label>
											<WtmLabelTooltip label="性别" tooltip="性别" />
										</template>
										<el-select v-model="stateData.vmModel.Entity.Gender" disabled clearable class="width100">
											<el-option v-for="option in GENDER_OPTIONS" :key="option" :value="option" :label="option"></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_Ethnicity_FormItem" prop="Entity.Ethnicity">
										<template #label>
											<WtmLabelTooltip label="民族" tooltip="民族" />
										</template>
										<el-select v-model="stateData.vmModel.Entity.Ethnicity" disabled clearable class="width100">
											<el-option key="汉族" value="汉族" label="汉族"></el-option>
											<el-option key="回族" value="回族" label="回族"></el-option>
											<el-option key="满族" value="满族" label="满族"></el-option>
											<el-option key="蒙古族" value="蒙古族" label="蒙古族"></el-option>
											<el-option key="壮族" value="壮族" label="壮族"></el-option>
											<el-option key="其他" value="其他" label="其他"></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<!-- 身体信息字段 -->
								<el-col :xs="24" :sm="12" class="mb20">
									<el-form-item
										ref="Entity_Height_FormItem"
										prop="Entity.Height"
										:rules="[{ required: true, message: '身高为必填项', trigger: 'blur' }]"
									>
										<template #label>
											<WtmLabelTooltip label="身高(cm)" tooltip="身高（厘米）" />
										</template>
										<el-input-number
											v-model="stateData.vmModel.Entity.Height"
											:min="0"
											:max="250"
											:precision="1"
											disabled
											clearable
											class="width100"
										></el-input-number>
									</el-form-item>
								</el-col>
								<el-col :xs="24" :sm="12" class="mb20">
									<el-form-item ref="Entity_Weight_FormItem" prop="Entity.Weight">
										<template #label>
											<WtmLabelTooltip label="体重(kg)" tooltip="体重（公斤）" />
										</template>
										<div style="display: flex; align-items: center; gap: 10px">
											<el-input-number
												v-model="stateData.vmModel.Entity.Weight"
												:min="0"
												:max="150"
												:precision="1"
												disabled
												clearable
												style="flex: 1"
											></el-input-number>
											<span v-if="stateData.vmModel.Entity.Weight" style="white-space: nowrap; color: #606266">
												≈ {{ (stateData.vmModel.Entity.Weight * 2).toFixed(1) }} 斤
											</span>
										</div>
									</el-form-item>
								</el-col>
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_HighestEducation_FormItem" prop="Entity.HighestEducation">
										<template #label>
											<WtmLabelTooltip label="最高学历" tooltip="最高学历" />
										</template>
										<el-select v-model="stateData.vmModel.Entity.HighestEducation" disabled clearable class="width100">
											<el-option v-for="option in EDUCATION_OPTIONS" :key="option" :value="option" :label="option"></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :xs="24" :sm="12" class="mb20">
									<el-form-item ref="Entity_MajorCategory_FormItem" prop="Entity.MajorCategory">
										<template #label>
											<WtmLabelTooltip label="专业大类" tooltip="专业大类" />
										</template>
										<el-select v-model="stateData.vmModel.Entity.MajorCategory" disabled clearable class="width100">
											<el-option key="化学工业" value="化学工业" label="化学工业"></el-option>
											<el-option key="工学" value="工学" label="工学"></el-option>
											<el-option key="理学" value="理学" label="理学"></el-option>
											<el-option key="医学" value="医学" label="医学"></el-option>
											<el-option key="农学" value="农学" label="农学"></el-option>
											<el-option key="管理学" value="管理学" label="管理学"></el-option>
											<el-option key="经济学" value="经济学" label="经济学"></el-option>
											<el-option key="法学" value="法学" label="法学"></el-option>
											<el-option key="文学" value="文学" label="文学"></el-option>
											<el-option key="教育学" value="教育学" label="教育学"></el-option>
											<el-option key="艺术学" value="艺术学" label="艺术学"></el-option>
											<el-option key="历史学" value="历史学" label="历史学"></el-option>
											<el-option key="哲学" value="哲学" label="哲学"></el-option>
											<el-option key="其他" value="其他" label="其他"></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :xs="24" :sm="12" class="mb20">
									<el-form-item ref="Entity_MajorName_FormItem" prop="Entity.MajorName">
										<template #label>
											<WtmLabelTooltip label="专业名称" tooltip="专业名称" />
										</template>
										<el-input v-model="stateData.vmModel.Entity.MajorName" disabled clearable class="width100"></el-input>
									</el-form-item>
								</el-col>
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_MaritalStatus_FormItem" prop="Entity.MaritalStatus">
										<template #label>
											<WtmLabelTooltip label="婚姻状况" tooltip="婚姻状况" />
										</template>
										<el-select v-model="stateData.vmModel.Entity.MaritalStatus" disabled clearable class="width100">
											<el-option key="未婚" value="未婚" label="未婚"></el-option>
											<el-option key="已婚" value="已婚" label="已婚"></el-option>
											<el-option key="离异" value="离异" label="离异"></el-option>
											<el-option key="丧偶" value="丧偶" label="丧偶"></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :xs="24" :sm="12" class="mb20">
									<el-form-item ref="Entity_FertilityStatus_FormItem" prop="Entity.FertilityStatus">
										<template #label>
											<WtmLabelTooltip label="生育状况" tooltip="生育状况" />
										</template>
										<el-select v-model="stateData.vmModel.Entity.FertilityStatus" disabled clearable class="width100">
											<el-option key="未育" value="未育" label="未育"></el-option>
											<el-option key="一育" value="一育" label="一育"></el-option>
											<el-option key="二育" value="二育" label="二育"></el-option>
											<el-option key="三育" value="三育" label="三育"></el-option>
											<el-option key="四育及以上" value="四育及以上" label="四育及以上"></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_PhotoId_FormItem" prop="Entity.PhotoId">
										<template #label>
											<WtmLabelTooltip label="照片" tooltip="请上传个人近身照" />
										</template>
										<wtm-upload-image v-model="stateData.vmModel.Entity.PhotoId" disabled clearable class="width100"></wtm-upload-image>
									</el-form-item>
								</el-col>
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item
										ref="Entity_IsLaborRelationshipTerminated_FormItem"
										prop="Entity.IsLaborRelationshipTerminated"
										:rules="[{ required: true, message: '请选择是否解除劳动合同', trigger: 'change' }]"
									>
										<template #label>
											<WtmLabelTooltip label="是否解除劳动合同" tooltip="上家单位劳动关系是否已解除" />
										</template>
										<el-select v-model="stateData.vmModel.Entity.IsLaborRelationshipTerminated" disabled clearable class="width100">
											<el-option key="是" :value="true" label="是"></el-option>
											<el-option key="否" :value="false" label="否"></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_IsVeteran_FormItem" prop="Entity.IsVeteran">
										<template #label>
											<WtmLabelTooltip label="是否退伍军人" tooltip="是否为退伍军人" />
										</template>
										<el-select v-model="stateData.vmModel.Entity.IsVeteran" disabled clearable class="width100">
											<el-option key="是" :value="true" label="是"></el-option>
											<el-option key="否" :value="false" label="否"></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col v-if="stateData.vmModel.Entity.IsVeteran === true" :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_VeteranCertificateId_FormItem" prop="Entity.VeteranCertificateId">
										<template #label>
											<WtmLabelTooltip label="退伍证图片" tooltip="退伍证图片" />
										</template>
										<wtm-upload-image v-model="stateData.vmModel.Entity.VeteranCertificateId" disabled clearable class="width100"></wtm-upload-image>
									</el-form-item>
								</el-col>
								<!-- 亲属关系相关字段 -->
								<el-col :xs="24" :sm="12" class="mb20">
									<el-form-item ref="Entity_HasRelativeInCompany_FormItem" prop="Entity.HasRelativeInCompany">
										<template #label>
											<WtmLabelTooltip label="亲属关系" tooltip="是否与本单位职工存在亲属关系" />
										</template>
										<el-select v-model="stateData.vmModel.Entity.HasRelativeInCompany" disabled clearable class="width100">
											<el-option key="是" :value="true" label="是"></el-option>
											<el-option key="否" :value="false" label="否"></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col v-if="stateData.vmModel.Entity.HasRelativeInCompany === true" :xs="24" :sm="12" class="mb20">
									<el-form-item ref="Entity_RelationshipType_FormItem" prop="Entity.RelationshipType">
										<template #label>
											<WtmLabelTooltip label="亲属关系" tooltip="与公司内员工的亲属关系类型" />
										</template>
										<el-select v-model="stateData.vmModel.Entity.RelationshipType" disabled clearable class="width100">
											<el-option key="父亲" value="父亲" label="父亲"></el-option>
											<el-option key="母亲" value="母亲" label="母亲"></el-option>
											<el-option key="配偶" value="配偶" label="配偶"></el-option>
											<el-option key="子女" value="子女" label="子女"></el-option>
											<el-option key="兄弟姐妹" value="兄弟姐妹" label="兄弟姐妹"></el-option>
											<el-option key="其他" value="其他" label="其他"></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col v-if="stateData.vmModel.Entity.HasRelativeInCompany === true" :xs="24" :sm="12" class="mb20">
									<el-form-item ref="Entity_RelativeName_FormItem" prop="Entity.RelativeName">
										<template #label>
											<WtmLabelTooltip label="亲属姓名" tooltip="公司内亲属的姓名" />
										</template>
										<el-input v-model="stateData.vmModel.Entity.RelativeName" disabled clearable class="width100"></el-input>
									</el-form-item>
								</el-col>
							</el-row>
						</div>

						<div class="form-section">
							<div class="section-title">
								<i class="_wtmicon _wtmicon-wxbzhanghu"></i>
								<span>身份信息</span>
							</div>

							<el-row :gutter="20">
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item
										ref="Entity_IdCardNo_FormItem"
										prop="Entity.IdCardNo"
										:rules="[{ required: true, message: '身份证号为必填项', trigger: 'blur' }]"
									>
										<template #label>
											<WtmLabelTooltip label="身份证号" tooltip="身份证号码" />
										</template>
										<el-input
											v-model="stateData.vmModel.Entity.IdCardNo"
											disabled
											clearable
											class="width100"
											placeholder="请上传身份证正反面照片"
										></el-input>
									</el-form-item>
								</el-col>
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_IdCardFrontPhotoId_FormItem" prop="Entity.IdCardFrontPhotoId">
										<template #label>
											<WtmLabelTooltip label="身份证人像面" tooltip="身份证人像面文件" />
										</template>
										<wtm-upload-image v-model="stateData.vmModel.Entity.IdCardFrontPhotoId" disabled clearable class="width100"></wtm-upload-image>
									</el-form-item>
								</el-col>
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_IdCardBackPhotoId_FormItem" prop="Entity.IdCardBackPhotoId">
										<template #label>
											<WtmLabelTooltip label="身份证国徽面" tooltip="身份证国徽面文件" />
										</template>
										<wtm-upload-image v-model="stateData.vmModel.Entity.IdCardBackPhotoId" disabled clearable class="width100"></wtm-upload-image>
									</el-form-item>
								</el-col>
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_IdCardExpiryDate_FormItem" prop="Entity.IdCardExpiryDate">
										<template #label>
											<WtmLabelTooltip label="身份证有效期" tooltip="身份证有效期" />
										</template>
										<el-input
											:value="other.formatIdCardExpiry(stateData.vmModel.Entity.IdCardExpiryDate)"
											disabled
											clearable
											class="width100"
											placeholder="上传身份证国徽面后自动填充"
										></el-input>
									</el-form-item>
								</el-col>
							</el-row>
						</div>

						<div class="form-section">
							<div class="section-title">
								<i class="_wtmicon _wtmicon-wxbzhanghu"></i>
								<span>户籍信息</span>
							</div>

							<el-row :gutter="20">
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_HouseholdRegistration_FormItem" prop="Entity.HouseholdRegistration">
										<template #label>
											<WtmLabelTooltip label="户口所在地" tooltip="户口所在地" />
										</template>
										<el-input v-model="stateData.vmModel.Entity.HouseholdRegistration" disabled clearable class="width100"></el-input>
									</el-form-item>
								</el-col>
								<!-- <el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_NativePlace_FormItem" prop="Entity.NativePlace">
										<template #label>
											<WtmLabelTooltip label="籍贯" tooltip="籍贯" />
										</template>
										<el-input v-model="stateData.vmModel.Entity.NativePlace" disabled clearable class="width100"></el-input>
									</el-form-item>
								</el-col> -->
							</el-row>
						</div>

						<div class="form-section">
							<div class="section-title">
								<i class="_wtmicon _wtmicon-wxbzhanghu"></i>
								<span>政治面貌</span>
							</div>

							<el-row :gutter="20">
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_PoliticalStatus_FormItem" prop="Entity.PoliticalStatus">
										<template #label>
											<WtmLabelTooltip label="政治面貌" tooltip="政治面貌" />
										</template>
										<el-select v-model="stateData.vmModel.Entity.PoliticalStatus" disabled clearable class="width100">
											<el-option key="共青团员" value="共青团员" label="共青团员"></el-option>
											<el-option key="中共党员" value="中共党员" label="中共党员"></el-option>
											<el-option key="群众" value="群众" label="群众"></el-option>
											<el-option key="无党派人士" value="无党派人士" label="无党派人士"></el-option>
											<el-option key="其他" value="其他" label="其他"></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<!-- <el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_PartyJoinDate_FormItem" prop="Entity.PartyJoinDate">
										<template #label>
											<WtmLabelTooltip label="入党(团)日期" tooltip="入党或入团日期" />
										</template>
										<el-date-picker v-model="stateData.vmModel.Entity.PartyJoinDate" disabled clearable class="width100"></el-date-picker>
									</el-form-item>
								</el-col> -->
								<!-- <el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_PartyBranch_FormItem" prop="Entity.PartyBranch">
										<template #label>
											<WtmLabelTooltip label="入党所在支部" tooltip="入党所在支部" />
										</template>
										<el-input v-model="stateData.vmModel.Entity.PartyBranch" disabled clearable class="width100"></el-input>
									</el-form-item>
								</el-col> -->
							</el-row>
						</div>

						<div class="form-section">
							<div class="section-title">
								<i class="_wtmicon _wtmicon-wxbzhanghu"></i>
								<span>联系方式</span>
							</div>

							<el-row :gutter="20">
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_HomeAddress_FormItem" prop="Entity.HomeAddress">
										<template #label>
											<WtmLabelTooltip label="现住址" tooltip="现在所居住的地址" />
										</template>
										<el-input v-model="stateData.vmModel.Entity.HomeAddress" disabled clearable class="width100"></el-input>
									</el-form-item>
								</el-col>
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item
										ref="Entity_Phone_FormItem"
										prop="Entity.Phone"
										:rules="[{ required: true, message: '手机号为必填项', trigger: 'blur' }]"
									>
										<template #label>
											<WtmLabelTooltip label="手机号" tooltip="手机号码" />
										</template>
										<el-input v-model="stateData.vmModel.Entity.Phone" disabled clearable class="width100"></el-input>
									</el-form-item>
								</el-col>
								<!-- <el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_Email_FormItem" prop="Entity.Email">
										<template #label>
											<WtmLabelTooltip label="邮箱" tooltip="电子邮箱" />
										</template>
										<el-input v-model="stateData.vmModel.Entity.Email" disabled clearable class="width100"></el-input>
									</el-form-item>
								</el-col> -->
							</el-row>
						</div>

						<div class="form-section">
							<div class="section-title">
								<i class="_wtmicon _wtmicon-wxbzhanghu"></i>
								<span>工作信息</span>
							</div>

							<el-row :gutter="20">
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_OrgId_FormItem" prop="Entity.OrgId">
										<template #label>
											<WtmLabelTooltip label="公司" tooltip="关联的公司" />
										</template>
										<el-select v-model="stateData.vmModel.Entity.OrgId" disabled clearable class="width100">
											<el-option v-for="item in stateData.AllSysOrgs" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
										</el-select>
									</el-form-item>
								</el-col>
								<el-col :xs="24" :lg="24" class="mb20">
									<WtmDeptSelector
										v-model:model-value="stateData.vmModel.Entity.GroupId"
										v-model:position-id="stateData.vmModel.Entity.JobPositionId"
										prop="Entity.GroupId"
										position-prop="Entity.JobPositionId"
										label="所属部门"
										position-label="工作岗位"
										:show-position="true"
										:use-row="true"
										:dept-col="12"
										:position-col="12"
										:disabled="true"
										:position-disabled="true"
									/>
								</el-col>
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_JoinWorkDate_FormItem" prop="Entity.JoinWorkDate">
										<template #label>
											<WtmLabelTooltip label="参加工作日期" tooltip="首次参加工作日期" />
										</template>
										<el-date-picker v-model="stateData.vmModel.Entity.JoinWorkDate" disabled clearable class="width100"></el-date-picker>
									</el-form-item>
								</el-col>
								<!-- 
								<el-col :xs="24" :lg="12" class="mb20">
									<el-form-item ref="Entity_EmploymentType_FormItem" prop="Entity.EmploymentType">
										<template #label>
											<WtmLabelTooltip label="用工形式" tooltip="用工形式" />
										</template>
										<el-select v-model="stateData.vmModel.Entity.EmploymentType" disabled clearable class="width100">
											<el-option v-for="option in EMPLOYMENT_TYPE_OPTIONS" :key="option" :value="option" :label="option"></el-option>
										</el-select>
									</el-form-item>
								</el-col> -->
							</el-row>
						</div>
					</el-form>
				</el-card>
			</el-tab-pane>
			<el-tab-pane label="学习经历" name="personeducations" v-if="stateData.vmModel.Entity.ID">
				<SysPersonEducation :search-bar="false" :toolbar="false" :is-disabled="true" :person-id="stateData.vmModel.Entity.ID" />
			</el-tab-pane>

			<el-tab-pane label="家庭成员" name="personfamilies" v-if="stateData.vmModel.Entity.ID">
				<SysPersonFamily :search-bar="false" :toolbar="false" :is-disabled="true" :person-id="stateData.vmModel.Entity.ID" />
			</el-tab-pane>

			<el-tab-pane label="工作经历" name="personworks" v-if="stateData.vmModel.Entity.ID">
				<SysPersonWork :search-bar="false" :toolbar="false" :is-disabled="true" :person-id="stateData.vmModel.Entity.ID" />
			</el-tab-pane>

			<!-- <el-tab-pane label="员工履历" name="personresumes" v-if="stateData.vmModel.Entity.ID">
				<SysPersonResume :search-bar="false" :toolbar="false" :is-disabled="true" :person-id="stateData.vmModel.Entity.ID" />
			</el-tab-pane> -->
			<el-tab-pane label="荣誉职称" name="personprofessionaltitles" v-if="stateData.vmModel.Entity.ID">
				<SysPersonProfessionalTitle :search-bar="false" :toolbar="false" :is-disabled="true" :person-id="stateData.vmModel.Entity.ID" />
			</el-tab-pane>

			<el-tab-pane label="审批信息" name="workflow">
				<WtmWorkflowTimeline entityType="HengTong.Model.Db.Bill.SysHrInterviewRequestBill" :entityId="stateData.vmModel.Entity.ID" />
			</el-tab-pane>
		</el-tabs>
	</div>
</template>

<script setup lang="ts" name="message._system.common.vm.edit;false">
import { reactive, ref, getCurrentInstance, onMounted, nextTick, computed, type ComponentInternalInstance, defineAsyncComponent } from 'vue';
import { ElMessage } from 'element-plus';
import { SysHrInterviewRequestBillApi as api } from '/@/views/hr/syshrinterviewrequestbill/api';
import { SysHrRecruitPublishRequestBillApi } from '/@/views/hr/syshrrecruitpublishrequestbill/api';
import { commonApi } from '/@/api/common';
import other from '/@/utils/other';
import { useRouter } from 'vue-router';
import { ISysHrInterviewRequestBillVm } from '/@/views/hr/syshrinterviewrequestbill/api/interface';
import { IViewModel } from '/@/types/common';
import ApproveReasonDialog from '/@/components/approveReason/index.vue';
import { FieldController } from '/@/utils/fieldControl';
import type { IPropertyControls } from '/@/views/fileattachment/api/interface';

import WtmWorkflowTimeline from '/@/components/workflowTimeline/index.vue';

// 懒加载子组件
const SysPersonEducation = defineAsyncComponent(() => import('/@/views/person/syspersoneducation/index.vue'));
const SysPersonFamily = defineAsyncComponent(() => import('/@/views/person/syspersonfamily/index.vue'));
const SysPersonWork = defineAsyncComponent(() => import('/@/views/person/syspersonwork/index.vue'));
const SysPersonTrainExam = defineAsyncComponent(() => import('/@/views/person/syspersontrainexam/index.vue'));
const SysPersonMedical = defineAsyncComponent(() => import('/@/views/person/syspersonmedical/index.vue'));
const SysPersonResume = defineAsyncComponent(() => import('/@/views/person/syspersonresume/index.vue'));
const SysPersonContract = defineAsyncComponent(() => import('/@/views/person/syspersoncontract/index.vue'));
const SysPersonProfessionalTitle = defineAsyncComponent(() => import('/@/views/person/syspersonprofessionaltitle/index.vue'));

// 常量定义
const BILL_STATUS_OPTIONS = ['草稿', '正文'] as const;

const WORKFLOW_STATUS_OPTIONS = ['待提交', '提交中', '审核中', '已完成', '已取消'] as const;

const WORKFLOW_STATUS = {
	PENDING: '待提交',
	SUBMITTING: '提交中',
	IN_AUDIT: '审核中',
	APPROVED: '已完成',
	CANCELLED: '已取消',
} as const;

const GENDER_OPTIONS = ['男', '女', '其他'] as const;

const EDUCATION_OPTIONS = ['小学', '初中', '高中', '中专', '大专', '本科', '研究生', '硕士', '博士', '博士后', '博士研究生', '其他'] as const;

const ACTIONS = {
	AGREE: '同意',
	REJECT: '拒绝',
} as const;

const BUTTON_TEXTS = {
	SAVE_INTERVIEW: '保存面试信息',
	APPROVE: '同意',
	REJECT: '拒绝',
	CLOSE: '关闭',
} as const;

const EMPLOYMENT_TYPE_OPTIONS = ['全职', '兼职', '实习', '外包'] as const;
const CONTRACT_TYPE_OPTIONS = ['固定期限', '无固定期限', '项目合同'] as const;
const RESIGNATION_TYPE_OPTIONS = ['主动离职', '被动离职', '退休'] as const;
const PERSON_STATE_OPTIONS = ['在职', '离职', '退休'] as const;

const ci = getCurrentInstance() as ComponentInternalInstance;
const loading = ref(false);
const formRef = ref();
const activeTab = ref('main');
const recruitPublishDisplayName = ref<string>('');

// 字段控制器
const fieldController = ref<FieldController>(new FieldController());

// 定义子组件向父组件传值事件
const emit = defineEmits(['refresh', 'closeDialog', 'updateHeaderButtons']);

const stateData = reactive<IViewModel<ISysHrInterviewRequestBillVm>>({
	vmModel: {
		Entity: {
			// 应聘信息
			ID: null,
			RecruitPublishRequestBillId: null,
			ArrivalDate: null,
			CurrentSalary: null,
			ExpectedSalary: null,
			WorkExperience: null,
			InitialTestTime: null,
			InitialResult: null,
			InitialComment: null,
			ReExamTime: null,
			ReExamResult: null,
			ReExamComment: null,
			FinalResult: null,
			FinalRemark: null,
			RejectReason: null,

			// 笔试信息
			WrittenTestTime: null,
			WrittenTestScore: null,
			WrittenTestResult: null,

			// 体检信息
			PhysicalExamTime: null,
			PhysicalExamResult: null,
			PhysicalExamRemark: null,

			// 岗前培训信息
			PreJobTrainingStartTime: null,
			PreJobTrainingEndTime: null,
			TrainingResult: null,
			TrainingComment: null,

			// 单据信息
			BillCode: null,
			BillStatus: null,
			WorkflowStatus: null,
			Remark: null,
			Approver: null,
			ApprovalTime: null,

			// 基本信息
			Name: null,
			StaffNo: null,
			BirthDate: null,
			Age: null,
			Gender: null,
			Ethnicity: null,
			HighestEducation: null,
			MaritalStatus: null,
			FertilityStatus: null,
			MajorCategory: null,
			MajorName: null,
			PhotoId: null,
			WorkYears: null,
			Order: null,

			// 身份信息
			IdCardNo: null,
			IdCardFrontPhotoId: null,
			IdCardBackPhotoId: null,
			IdCardExpiryDate: null,

			// 户籍信息
			HouseholdRegistration: null,
			NativePlace: null,

			// 政治面貌
			PoliticalStatus: null,
			PartyJoinDate: null,
			PartyBranch: null,
			ArchiveLocation: null,
			ArchiveNo: null,
			ArchiveTransferOutDate: null,
			ArchiveTransferInDate: null,

			// 联系方式
			HomeAddress: null,
			Phone: null,
			Email: null,

			// 银行账户
			SalaryBank: null,
			SalaryAccount: null,
			BonusBank: null,
			BonusAccount: null,

			// 工作信息
			OrgId: null,
			GroupId: null,
			JobPositionId: null,
			ResumeId: null,
			HireDate: null,
			ConfirmationDate: null,
			EmploymentType: null,
			ContractType: null,
			ContractNo: null,
			ContractStartDate: null,
			ContractEndDate: null,
			ResignationDate: null,
			ResignationReason: null,
			ResignationType: null,
			State: null,

			// 其他
			BloodType: null,
			Hobbies: null,
			IsVeteran: null,
			VeteranCertificateId: null,
			CompanyYears: null,
			JoinWorkDate: null,
			ArchiveAgeDate: null,

			// 新增字段 - 亲属关系
			HasRelativeInCompany: null,
			RelationshipType: null,
			RelativeName: null,
			IsLaborRelationshipTerminated: false,

			// 新增字段 - 身体信息
			Height: null,
			Weight: null,
		} as any,
		ActionName: null,
		IsMyApprove: false,
		Remark: null,
	},
	AllSysOrgs: [],
	AllSysGroups: [],
	AllSysJobPositions: [],
});

// 计算属性
const isInAudit = computed(() => stateData.vmModel.Entity?.WorkflowStatus === WORKFLOW_STATUS.IN_AUDIT);
const canApprove = computed(() => stateData.vmModel.IsMyApprove && isInAudit.value);

// 统一的错误处理函数
const handleError = (error: any) => {
	other.setFormError(ci, error);
	loading.value = false;
};

// 统一的成功处理函数
const handleSuccess = (response: any, isSubmit = false, isApproval = false) => {
	if (isApproval) {
		ElMessage.success('审批操作完成');
	} else {
		ElMessage.success(ci.proxy?.$t('message._system.common.vm.submittip') || '操作成功');
	}

	emit('refresh');

	if (isSubmit || isApproval) {
		closeDialog();
	}

	loading.value = false;

	nextTick(() => {
		setupHeaderButtons();
	});
};

// 公共的审批处理函数
const handleApproval = (actionName: string) => {
	stateData.vmModel.ActionName = actionName;
	loading.value = true;

	// 先保存面试信息
	api()
		.edit(stateData.vmModel)
		.then(() => {
			// 保存成功后进行审批
			return api().approve(stateData.vmModel, '');
		})
		.then((response: any) => handleSuccess(response, false, true))
		.catch(handleError);
};

// 关闭弹窗
const closeDialog = () => {
	emit('closeDialog');
};

// 同意
const onAgree = () => {
	other.openDialog('填写同意原因', ApproveReasonDialog, null, null, '30%', (reason: string) => {
		stateData.vmModel.Remark = reason;
		handleApproval(ACTIONS.AGREE);
	});
};

// 拒绝
const onDeny = () => {
	other.openDialog('填写拒绝原因', ApproveReasonDialog, { isRequired: true }, null, '30%', (reason: string) => {
		stateData.vmModel.Remark = reason;
		handleApproval(ACTIONS.REJECT);
	});
};

// 初始化页面数据
const initializePageData = () => {
	const wtmdata = ci.attrs['wtmdata'] as any;
	const routeId = useRouter().currentRoute.value.query.id;

	if (wtmdata?.ID) {
		stateData.vmModel.Entity.ID = wtmdata.ID;
	} else if (routeId) {
		stateData.vmModel.Entity.ID = routeId as string;
	}
};

// 加载选择列表数据
const loadSelectListData = async () => {
	const [orgs, jobPositions] = await Promise.allSettled([commonApi().getOrganizations(), commonApi().getJobPositions({})]);

	// 处理成功的结果
	if (orgs.status === 'fulfilled') stateData.AllSysOrgs = orgs.value;
	if (jobPositions.status === 'fulfilled') stateData.AllSysJobPositions = jobPositions.value;
};

// 加载招聘发布单详细信息
const loadRecruitPublishInfo = async () => {
	if (stateData.vmModel.Entity.RecruitPublishRequestBillId) {
		try {
			// 使用search方法获取所有招聘发布单数据，与编辑页保持一致
			const response = await SysHrRecruitPublishRequestBillApi().search({ IsExternalPublish: true });
			if (response.Data) {
				// 根据当前选中的RecruitPublishRequestBillId找到对应的招聘发布单
				const selectedPublish = response.Data.find((item: any) => item.ID === stateData.vmModel.Entity.RecruitPublishRequestBillId);
				if (selectedPublish) {
					// 使用类型断言处理动态字段
					const billCode = selectedPublish.BillCode || '';
					const title = selectedPublish.Title || '未知标题';
					recruitPublishDisplayName.value = `${billCode} - ${title}`;
				} else {
					recruitPublishDisplayName.value = '未找到对应的招聘发布单';
				}
			}
		} catch (error) {
			console.error('获取招聘发布单详细信息失败:', error);
			recruitPublishDisplayName.value = '获取失败';
		}
	}
};

// 初始化字段控制器
const initializeFieldController = (data: any) => {
	// 检查API返回的数据中是否包含PropertyControls
	const propertyControls: IPropertyControls = data?.PropertyControls || [];
	fieldController.value = new FieldController(propertyControls);
};

// 加载实体数据
const loadEntityData = async () => {
	if (stateData.vmModel.Entity.ID) {
		const data = await api().get(stateData.vmModel.Entity.ID);
		other.setValue(stateData.vmModel, data);

		// 初始化字段控制器
		initializeFieldController(data);

		// 加载实体数据后，加载招聘发布单信息
		await loadRecruitPublishInfo();
	}
};

// 设置对话框头部按钮
const setupHeaderButtons = () => {
	const headerButtons = [
		{
			text: BUTTON_TEXTS.APPROVE,
			type: 'primary',
			onClick: onAgree,
			visible: canApprove.value,
		},
		{
			text: BUTTON_TEXTS.REJECT,
			type: 'danger',
			onClick: onDeny,
			visible: canApprove.value,
		},
		{
			text: BUTTON_TEXTS.CLOSE,
			type: 'default',
			onClick: closeDialog,
			visible: true,
		},
	];

	emit('updateHeaderButtons', headerButtons);
};

// 页面加载时
onMounted(async () => {
	loading.value = true;

	try {
		// 先初始化页面数据（获取ID）
		initializePageData();

		// 并行加载数据
		await Promise.allSettled([loadSelectListData(), loadEntityData()]);
	} catch (error) {
		handleError(error);
	} finally {
		loading.value = false;
		nextTick(() => {
			setupHeaderButtons();
		});
	}
});
</script>

<style scoped>
/* 面试信息区块样式 */
.interview-section {
	background: #fafafa;
	border: 1px solid #e8eaec;
	border-radius: 6px;
	padding: 20px;
	margin-bottom: 20px;
}

.interview-section-title {
	display: flex;
	align-items: center;
	font-size: 16px;
	font-weight: 600;
	color: #303133;
	margin-bottom: 0;
	padding-bottom: 12px;
	border-bottom: 2px solid #e8eaec;
}

.interview-section-title i {
	margin-right: 8px;
	font-size: 18px;
	color: #409eff;
}

/* 最终结果区块特殊样式 */
.final-result-section {
	background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
	border: 2px solid #e8eaec;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.final-result-section .interview-section-title {
	color: #2c3e50;
	border-bottom: 2px solid #409eff;
}

.final-result-section .interview-section-title i {
	color: #f39c12;
}

/* 响应式布局优化 */
@media (max-width: 768px) {
	.interview-section {
		padding: 15px;
	}

	.interview-section-title {
		font-size: 14px;
	}

	.interview-section-title i {
		font-size: 16px;
	}
}

/* 表单项间距优化 */
.mt20 {
	margin-top: 20px;
}

.mb30 {
	margin-bottom: 30px;
}

/* 选择框选项美化 */
.el-select-dropdown__item span {
	display: flex;
	align-items: center;
	gap: 8px;
}

/* 文本框占位符样式 */
.el-textarea__inner::placeholder {
	color: #c0c4cc;
	font-style: italic;
}
</style>
